<?php
include("../includes/common.php");
if($islogin2==1){}else exit("<script language='javascript'>window.location.href='./login.php';</script>");
include './head.php';
?>

<div class="clearfix"></div>  
  <div class="content-wrapper">
    <div class="container-fluid">
     <div class="row pt-2 pb-2">
        <div class="col-sm-9">
            <h4 class="page-title">收款信息</h4>
            <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="javaScript:void();">收款</a></li>
            <li class="breadcrumb-item"><a href="javaScript:void();">账号</a></li>
            <li class="breadcrumb-item active" aria-current="page">信息</li>
         </ol>
       </div>
     </div>
      <div class="row">
        <div class="col-lg-8">
           <div class="card">
            <div class="card-body">
                <div class="tab-pane" id="edit">           
                <div class="form-group row">
                  <label for="basic-select" class="col-sm-3 col-form-label">结算方式：</label>
                  <div class="col-sm-9">

                  <select class="form-control" id='stype' name="stype" default="<?php echo $userrow['settle_id']?>">
                        <?php if($conf['stype_1']){?><option value="1" >支付宝结算</option>
                        <?php }if($conf['stype_2']){?><option value="2" >微信结算</option>
                        <?php }if($conf['stype_3']){?><option value="3">QQ钱包结算</option>
                        <?php }if($conf['stype_4']){?><option value="4">银行卡结算</option>
                        <?php }?></select> 
                  </div>
                </div>
                      
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">收款账号:</label>
                            <div class="col-lg-9">
                                <input class="form-control" type="text" id='account' name="account" value="<?php echo $userrow['account']?>" placeholder="请输入收款账号" required="required">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">收款姓名:</label>
                            <div class="col-lg-9">
                                <input class="form-control" type="text" name="username" id='username' value="<?php echo $userrow['username']?>" placeholder="请输入收款姓名" required="required">
                            </div>
                        </div>
                       
                       
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label"></label>
                            <div class="col-lg-9">
                                <input type="button" id="checkbind" value="确定提交" class="btn btn-secondary btn-square waves-effect waves-light m-1">
                        
                         </div>
                        </div>
                </div>
            </div>
        </div>
      </div>

     <div class="col-lg-8">
          <div class="card">
            <div class="card-header text-uppercase">关于商户收款信息注意事项：</div>
             <div class="card-body">
                <ul class="list-group">
                    <li class="list-group-item list-group-item-primary">结算账号：请注意不要填写错误,填错我们概不负责</li>
                    <li class="list-group-item list-group-item-secondary">结算姓名：请务必填写真实姓名，否则出款失败后果自负</li>
                  </ul>
             </div>
          </div>
        </div>
      </div> 
    </div>
    </div>
   </div>
    <a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>

    
         
            
<?php include 'foot.php';?>
<script>
$("#checkbind").click(function(){
            if($(this).attr('isbind')==1)
                situationshow("yanz");
            else
                situationshow("yanz2");
            $.ajax({
                type : "GET",
                url : "ajax2.php?act=checkbind",
                dataType : 'json',
                success : function(data) {
                    if(data.code == 1){
                        
                    }else if(data.code == 2){
                        
                    }else{
                        layer.alert(data.msg);
                    }
                }
            });
        });
  
    function situationshow(situation){
            layer.open({
                type: 1,
                skin: 'layui-layer-rim', //加上边框
                area: ['420px', '240px'], //宽高
                btn:['确认','关闭'],
                title:'验证密保信息',
               content: "<div class=\"form-group row\">\n" +
                    "    <label class=\"col-lg-3 col-form-label form-control-label\">密保邮箱：</label>\n" +
                    "    <div class=\"col-lg-8\">\n" +
                    "        <input id='email-use' type=\"email\" style='background:white;' name=\"title\" lay-verify=\"title\" <?php if($userrow['email'])echo 'readonly';  ?> autocomplete=\"off\" value=\"<?php echo $userrow['email'];?>\" placeholder=\"请输入邮箱\" class=\"form-control\">\n" +
                    "    </div>\n" +
                    "</div>\n" +
                    "<div class=\"layui-form-item\" style='white-space:nowrap;'>\n" +
                    "\n" +

                    "        <input id='veify-win' type=\"text\" name=\"title\" lay-verify=\"title\" autocomplete=\"off\" placeholder=\"请输入验证码\"  style=\"float:left;width:72%;background:white;\" class=\"form-control\">\n" +

                    "    <button class=\"btn btn btn-danger  waves-effect waves-light m-1\" id=\"sendver_win\"  style='float:right'>获取验证码</button>\n" +
                    "</div>",
                yes:function(){
                    var veify=$('#veify-win').val();
                    if(''==veify){
                        layer.alert('请输入验证码！');
                        return false;
                    }
                    $.post('/user/ajax2.php?act=verifycode',{code:veify},function(data){
                        if(data.code=='-1'){
                            layer.alert(data.msg);

                        }else{

                           
                             $.post('/user/ajax2.php?act=edit_settle',{stype:$('#stype').val(),account:$('#account').val(),username:$('#username').val()},function(datas){
                                if(datas.code=='1'){
                                    layer.msg('操作成功');
                                    setTimeout(function(){
                                        location.reload();
                                    },800);
                                }else{
                                    layer.alert(datas.msg);
                                }
                            });

                        }



                    });

                } ,success(){
                    $('#sendver_win').click(function(){
                        sendver_win(situation);
                    });

                }

            });
        }
        /*获取验证码*/
        function sendver_win(situation){

            var ema=$('#email-use').val();
            if(ema==""){
                layer.alert("请输入邮箱");
                return false;
            }

            var myReg=/^[a-zA-Z0-9_-]+@([a-zA-Z0-9]+\.)+(com|cn|net|org)$/;

            if(myReg.test(ema)){

            }else{
                layer.alert("邮箱格式不对!");
                return false;
            }


            $.ajax({
                type : "POST",
                url : "ajax2.php?act=sendcode",
                data : {
                    situation:situation,
                    email:ema
                },
                dataType : 'json',
                success : function(data) {

                    if(data.code == 0){
                        layer.msg('发送成功，请注意查收！');

                        set_sendemail_time($('#sendver_win'));
                    }else{
                        layer.alert(data.msg);

                    }
                }
            });

        }
        function set_sendemail_time(th){
            th.attr('disabled',true);
            var time=60;
            th.prev().css("width",'60%');
            th.html(time+' 秒后可再次发送');
            var seti1=setInterval(function(){
                if(time--!=0){
                    th.html(time+' 秒后可再次发送');
                }else{
                    th.attr('disabled',false);
                    clearInterval(seti1);
                    th.prev().css("width",'72%');
                    th.html('获取验证码');
                }
            },1000);
        }




</script>
<script>
var items = $("select[default]");
for (i = 0; i < items.length; i++) {
	$(items[i]).val($(items[i]).attr("default")||0);
}
</script>